let base = {
	baseUrl: 'http://localhost:9090',
	// baseUrl: 'http://192.168.0.114:9400/',
	ajax(options) {
		let url = this.baseUrl + options.url
		wx.request({
			url: url,
			method: options.method ? options.method : 'POST',
			data: options.data,
			header: {
				'content-type': options.method == 'POST' ? 'application/x-www-form-urlencoded' :
					'application/json'
			},
			success: function(res) {
				options.success && options.success(res.data);
			}
		})
	},
	//显示消息提示框
	toast: function(options) {
		wx.showToast({
			title: options.title ? options.title : '成功',
			icon: options.icon ? options.icon : 'none',
			duration: 3000,
			success: function(res) {
				if (res.errMsg == 'showToast:ok') {
					options.success && options.success(res);
				}
			}
		})
	},
	//模态对话框
	modal: function(options) {
		wx.showModal({
			title: options.title ? options.title : '提示',
			content: options.content ? options.content : '这是一个模态弹窗',
			success(res) {
				if (res.confirm) {
					options.success && options.success(res);
				} else if (res.cancel) {
					options.cancel && options.cancel(res);
				}
			}
		})
	},
}
export {
	base
};
